package com.holyant.goods.dto;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.holyant.goods.enums.SpecsQtyEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;

/**
 * 商品报价dto
 * 
 * @author g
 * @date 2022-02-08
 */
@Data
@ApiModel("商品报价")
public class GdsSkuQuoteImportDto {

    @Excel(name = "客户")
    @ApiModelProperty(value = "客户")
    @NotNull(message = "客户名称不能为空", groups = {GuideGroup.class})
    @NotEmpty(message = "客户名称不能为空", groups = {GuideGroup.class})
    private String enterpriseName;

    public interface GuideGroup {}

    /** 渠道 */
    @Excel(name = "渠道类型", prompt = "C2P, POP, B2B(HK), B2B(MO), KA, WM")
    @ApiModelProperty(value = "渠道类型")
    @NotNull(message = "渠道不能为空", groups = {GuideGroup.class})
    @NotEmpty(message = "渠道不能为空", groups = {GuideGroup.class})
    @Pattern(regexp="^(C2P|POP|B2B\\(HK\\)|B2B\\(MO\\)|KA|WM)$", message = "渠道类型格式不正确", groups = {GuideGroup.class})
    private String salesChannelString;

    /** 报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税 */
    @Excel(name = "报价方式", prompt = "包邮不包税, 包邮包税, 不包邮不包税")
    @ApiModelProperty(value = "报价方式 10：包邮不包税，20：包邮包税，30: 不包邮不包税")
    @Pattern(regexp="^(包邮不包税|包邮包税|不包邮不包税)$", message = "报价方式格式不正确", groups = {GuideGroup.class})
    private String quoteMethodString;

    /** sku编码 */
    @Excel(name = "sku编码")
    @ApiModelProperty(value = "sku编码")
    @NotNull(message = "sku编码不能为空", groups = {GuideGroup.class})
    @NotEmpty(message = "sku编码不能为空", groups = {GuideGroup.class})
    private String skuCode;

    /** 商品名称 */
    @Excel(name = "商品名称", width = 30)
    @ApiModelProperty(value = "商品名称")
    @NotNull(message = "商品名称不能为空", groups = {GuideGroup.class})
    @NotEmpty(message = "商品名称不能为空", groups = {GuideGroup.class})
    private String goodsName;

    /** 商品条码 */
    @Excel(name = "国际条码")
    @ApiModelProperty(value = "国际条码")
    @NotNull(message = "国际条码不能为空", groups = {GuideGroup.class})
    @NotEmpty(message = "国际条码不能为空", groups = {GuideGroup.class})
    private String goodsBarcode;

    /** 商品效期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "效期", prompt = "例: 2025-2-11")
    @ApiModelProperty(value = "效期")
    private String expireDateString;

    /** 币种 */
    @Excel(name = "币种", prompt = "人民币, 港币")
    @ApiModelProperty(value = "币种")
    @NotNull(message = "币种不能为空", groups = {GuideGroup.class})
    @NotEmpty(message = "币种不能为空", groups = {GuideGroup.class})
    @Pattern(regexp="^(人民币|港币)$", message = "币种格式不正确", groups = {GuideGroup.class})
    private String curTypeString;

    @Excel(name = "1 pcs", defaultValue = "0")
    private BigDecimal pcs1;

    @Excel(name = "2 pcs", defaultValue = "0")
    private BigDecimal pcs2;

    @Excel(name = "3 pcs", defaultValue = "0")
    private BigDecimal pcs3;

    @Excel(name = "4 pcs", defaultValue = "0")
    private BigDecimal pcs4;

    @Excel(name = "5 pcs", defaultValue = "0")
    private BigDecimal pcs5;

    @Excel(name = "6 pcs", defaultValue = "0")
    private BigDecimal pcs6;

    @Excel(name = "备注")
    @ApiModelProperty(value = "备注")
    private String remark;

    /** 生效开始日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "价格生效时间", prompt = "例: 2022-2-11")
    @ApiModelProperty(value = "价格生效时间")
    private String effectiveDateStartString;

    /** 生效结束日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "价格失效时间", prompt = "大于或等于价格生效时间, 例: 2022-2-22")
    @ApiModelProperty(value = "价格失效时间")
    private String effectiveDateEndString;

    public JSONObject getPriceObj() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(SpecsQtyEnum.ONE.name(), pcs1);
        jsonObject.put(SpecsQtyEnum.TWO.name(), pcs2);
        jsonObject.put(SpecsQtyEnum.THREE.name(), pcs3);
        jsonObject.put(SpecsQtyEnum.FOUR.name(), pcs4);
        jsonObject.put(SpecsQtyEnum.FIVE.name(), pcs5);
        jsonObject.put(SpecsQtyEnum.SIX.name(), pcs6);
        return jsonObject;
    }

}
